package com.cneiu.ppms.web.action;

import com.cneiu.ppms.web.base.BaseController;
import com.cneiu.ppms.web.model.TransParamModel;
import com.cneiu.ppms.web.service.TransParamService;
import com.jfinal.plugin.activerecord.Page;
/**
 * 变压器参数控制器
 * @author zhaokf
 * @date 2013-04-23
 */
public class TransParamController extends BaseController{
	
	
	/**
	 * 查询全部数据集合
	 */
	public void list(){
		Page<TransParamModel> actions = TransParamService.list(this.getParams());
		if (null != actions){
			renderGrid(actions.getList());
		}else{
			renderAjax(false, TransParamService.getError());
		}
	}
	
	/**
	 * 变压器参数添加
	 */
	public void add(){
		try{
			if(!TransParamService.isAdd(this.getParams())){
				renderAjax(false, TransParamService.getError());
			}else{
				renderAjax(true, "添加变压器参数信息成功");
			}
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	/**
	 * 变压器参数编辑
	 */
	public void edit(){
		try{
			if(!TransParamService.isUpdate(this.getParams())){
				renderAjax(false, TransParamService.getError());
			}else{
				renderAjax(true, "修改变压器参数信息成功");
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}
	

	/**
	 * 根据ID查询变压器参数
	 */
	public void get(){
		try{
			TransParamModel model = TransParamService.get(this.getParams());
			renderGrid(model);
		}catch (Exception e){
			e.printStackTrace();
		}
	}

	/**
	 * 变压器参数删除
	 */
	public void delete(){
		try{
			if (!TransParamService.isDelete(this.getParams())){
				renderAjax(false, TransParamService.getError());
			}else{
				renderAjax(true, "删除变压器参数信息成功");
			}
		}
		catch (Exception e){
			e.printStackTrace();
		}
	}
}